//
//  GoOutSpecialTopicDetialViewController.m
//  ArtOfLiving
//
//  Created by 刘虎 on 16/5/1.
//  Copyright © 2016年 刘虎. All rights reserved.
//

#import "GoOutSpecialTopicDetialViewController.h"

@interface GoOutSpecialTopicDetialViewController ()<UIWebViewDelegate>

@property (weak, nonatomic) IBOutlet UIWebView *webView;

@end

@implementation GoOutSpecialTopicDetialViewController

- (void)viewDidLoad {
    
    [super viewDidLoad];
    self.navigationItem.title = self.navcTitle;
    self.automaticallyAdjustsScrollViewInsets = NO;
    self.webView.delegate = self;
    [self.webView loadRequest:[NSURLRequest requestWithURL:[NSURL URLWithString:self.htmlUrl]]];
    self.webView.scrollView.bounces = NO;
    self.tabBarController.tabBar.hidden = YES;
    
}

- (void)didReceiveMemoryWarning {
    [super didReceiveMemoryWarning];
    // Dispose of any resources that can be recreated.
}

#pragma mark - ----webView的代理方法----
- (void)webViewDidFinishLoad:(UIWebView *)webView {
    
    [webView stringByEvaluatingJavaScriptFromString:[NSString stringWithFormat:
                                                     @"var script = document.createElement('script');"
                                                     "script.type = 'text/javascript';"
                                                     "script.text = \"function ResizeImages() { "
                                                     "var myimg,oldwidth;"
                                                     "var maxwidth = %g;" // UIWebView中显示的宽度
                                                     "for(i=0;i <document.images.length;i++){"
                                                     "myimg = document.images[i];"
                                                     "if(myimg.width > maxwidth){"
                                                     "oldwidth = myimg.width;"
                                                     "myimg.width = maxwidth;"
                                                     "}"
                                                     "}"
                                                     "}\";"
                                                     "document.getElementsByTagName('head')[0].appendChild(script);",kScreenWidth]];
    [webView stringByEvaluatingJavaScriptFromString:@"ResizeImages();"];
    [webView stringByEvaluatingJavaScriptFromString:@"document.getElementsByClassName('content')[1].style.display = 'none'"];

}

@end
